<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Rag Hu
 * Created Time: 2019/7/2 11:22
 * Modified Time: 2019/7/2 11:22
 * Version: 2.0
 */

namespace App\Models;


use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class GoodsCategory extends Model
{

    protected $table = 'goods_category';

    protected $fillable = [
        'store_id',
        'parent_id',
        'name',
        'status'
    ];

    public function children(){
        return $this->hasMany(get_class($this),'parent_id','id');
    }

    public function goods(){
        return $this->hasMany(Goods::class,'cat_id','id');
    }

    public function parent(){
        return $this->hasOne(get_class($this),'id','parent_id');
    }

}